﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace chihuopig.Web.verfiy
{
    public static class ModelStateVefify
    {
        public static JsonMsg Vefifymsg(ModelStateDictionary modelStata)
        {
            JsonMsg err = new JsonMsg();

            foreach (var item in modelStata.Keys)
            {
                if (modelStata[item].Errors.Count<=0)
                {
                    continue;
                }

                foreach (var ErrorKey in modelStata[item].Errors)
                {
                    err.succeed = false;
                    err.msg = ErrorKey.ErrorMessage;
                    return err;
                }
            }
            return err;
        }
    }
}
